import express from 'express';
import cors from 'cors';

const app = express();

app.use(cors());
app.use(express.json());

// 产品数据 API
app.get('/api/product', (req, res) => {
    res.json({
        name: 'HUAWEI Pura70 Pro+',
        price: 8979,
        storage: '256GB',
        details: {
            size: '长度 160 mm 宽度 16.1 mm 厚度 0.3 mm',
            weight: '约 219g（含电池）',
            screen: '6.8 英寸 OLED',
            memory: '16GB RAM + 512GB/1TB ROM'
        }
    });
});

// 产品列表 API
app.get('/api/products', (req, res) => {
    res.json({
        data: [
            {
                id: 1,
                name: 'HUAWEI Pura70 Pro+',
                price: 8979,
                description: '旗舰影像手机',
                image: '/images/pura70-pro-plus.jpg'
            },
            {
                id: 2,
                name: 'HUAWEI Pura70 Pro',
                price: 6999,
                description: '专业影像手机',
                image: '/images/pura70-pro.jpg'
            },
            {
                id: 3,
                name: 'HUAWEI Pura70',
                price: 5499,
                description: '时尚影像手机',
                image: '/images/pura70.jpg'
            }
        ]
    });
});

app.listen(3001, () => {
    console.log('Server running on http://localhost:3001');
});